package com.chengwang.bookstory.service.Imple;

import com.chengwang.bookstory.mapper.TypeMapper;
import com.chengwang.bookstory.service.TypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TypeServiceImple implements TypeService {
    @Autowired
    TypeMapper typeMapper;
    @Override
    public void addType(String type) {
        List<String> typeList = typeMapper.queryAllType();
        System.out.println(typeList);
        boolean b = typeList.contains(type);

        if(!b){
            typeMapper.addType(type);
            System.out.println("添加分类进入");
        }

    }

    @Override
    public List<String> queryAllType() {
        return typeMapper.queryAllType();
    }

    @Override
    public void deleteType(String type) {
        typeMapper.deleteType(type);
    }

    @Override
    public void updateType(String type1, String type2) {
        typeMapper.updateType(type1,type2);
    }
}
